<template>
  <div class="home-container">
    <div class="overall-container-box">
      <div class="menus">
        <div class="menu-item" v-for="item in navList" :key="item.id" @click="gotoPage(item.name)">
          <img :src="item.pic" alt="">
          <span>{{item.title}}</span>
        </div>
      </div>
      <!--  -->
      <div class="wenhua">
        <div class="container-box">
        <div class="title">文化&治理</div>
        <div class="acount-statistics">
          <div class="statistics-item gutter">
            <div class="label">学堂发布<br/>数量</div>
            <div class="content">
              <div class="account">1256</div>
            </div>
          </div>
          <div class="statistics-item gutter">
            <div class="label">话题<br/>数量</div>
            <div class="content">
              <div class="account">456667</div>
            </div>
          </div>
          <div class="statistics-item gutter">
            <div class="label">社区公告发布<br/>数量</div>
            <div class="content">
              <div class="account">598561</div>
            </div>
          </div>
          <div class="statistics-item">
            <div class="label">活动组织<br/>数量</div>
            <div class="content">
              <div class="account">1234</div>
            </div>
          </div>
          <div class="statistics-item">
            <div class="label">事故处置<br/>数量</div>
            <div class="content">
              <div class="account">3445</div>
            </div>
          </div>
          <div class="statistics-item">
            <div class="label">累计服务<br/>人次</div>
            <div class="content">
              <div class="account">4466713</div>
            </div>
          </div>
        </div>
        </div>
        <div style="width: 5px"></div>
        <div class="container-box">
        <div class="title">居民健康</div>
        <div class="acount-statistics">
          <div class="statistics-item gutter">
            <div class="label">新冠疫苗接种<br/>人数</div>
            <div class="content">
              <div class="account" style="color:#15BE50;">6203</div>
            </div>
          </div>
          <div class="statistics-item gutter">
            <div class="label">健康码数量<br/>（黄码）</div>
            <div class="content">
              <div class="account" style="color:#FF6B00;">0</div>
            </div>
          </div>
          <div class="statistics-item gutter">
            <div class="label">健康码数量<br/>（红码）</div>
            <div class="content">
              <div class="account" style="color:#D40000;">0</div>
            </div>
          </div>
          <div class="statistics-item">
            <div class="label">残疾人<br/>数量</div>
            <div class="content">
              <div class="account">220</div>
            </div>
          </div>
          <div class="statistics-item">
            <div class="label">医保覆盖<br/>人数</div>
            <div class="content">
              <div class="account">6103</div>
            </div>
          </div>
          <div class="statistics-item">
            <div class="label">健康屋<br/>使用人数</div>
            <div class="content">
              <div class="account">2305</div>
            </div>
          </div>
        </div>
        </div>

      </div>
      <!--  -->
      <div class="shequ">
        <div class="container-box">
          <div class="title">社区概况</div>
          <div class="acount-statistics">
            <div class="statistics-item">
              <div class="label">居民总数</div>
              <div class="content">
                <div class="icon">
                  <img src="@/assets/img/people.png" alt="">
                </div>
                <div class="account">6638</div>
              </div>
            </div>
            <div class="statistics-item">
              <div class="label">总建筑面积</div>
              <div class="content">
                <div class="icon">
                  <img src="@/assets/img/fangyuan.png" alt="">
                </div>
                <div class="account">38.4万k㎡</div>
              </div>
            </div>
            <div class="statistics-item">
              <div class="label">停车位总数</div>
              <div class="content">
                <div class="icon">
                  <img src="@/assets/img/dache.png" alt="">
                </div>
                <div class="account">1700</div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!--  -->
      <div class="map-box">
        <div class="title">社区全貌</div>
        <div class="map">
          <a-map :location="[121.161744, 28.862611]"></a-map>
        </div>        
      </div>

    </div>
    <div class="right">
        <Right></Right>
    </div>
    <!-- <div class="right-col">
      <div class="container-box">
        <div class="title">社区概况</div>
        <div class="acount-statistics">
          <div class="statistics-item">
            <div class="label">居民总数</div>
            <div class="content">
              <div class="icon">
                <img src="@/assets/img/people.png" alt="">
              </div>
              <div class="account">6638</div>
            </div>
          </div>
          <div class="statistics-item">
            <div class="label">总建筑面积</div>
            <div class="content">
              <div class="icon">
                <img src="@/assets/img/fangyuan.png" alt="">
              </div>
              <div class="account">38.4万k㎡</div>
            </div>
          </div>
          <div class="statistics-item">
            <div class="label">停车位总数</div>
            <div class="content">
              <div class="icon">
                <img src="@/assets/img/dache.png" alt="">
              </div>
              <div class="account">1700</div>
            </div>
          </div>
        </div>
      </div>
      <div class="container-box">
        <div class="title">居民健康</div>
        <div class="acount-statistics">
          <div class="statistics-item gutter">
            <div class="label">新冠疫苗接种<br/>人数</div>
            <div class="content">
              <div class="account" style="color:#15BE50;">6203</div>
            </div>
          </div>
          <div class="statistics-item gutter">
            <div class="label">健康码数量<br/>（黄码）</div>
            <div class="content">
              <div class="account" style="color:#FF6B00;">0</div>
            </div>
          </div>
          <div class="statistics-item gutter">
            <div class="label">健康码数量<br/>（红码）</div>
            <div class="content">
              <div class="account" style="color:#D40000;">0</div>
            </div>
          </div>
          <div class="statistics-item">
            <div class="label">残疾人<br/>数量</div>
            <div class="content">
              <div class="account">220</div>
            </div>
          </div>
          <div class="statistics-item">
            <div class="label">医保覆盖<br/>人数</div>
            <div class="content">
              <div class="account">6103</div>
            </div>
          </div>
          <div class="statistics-item">
            <div class="label">健康屋<br/>使用人数</div>
            <div class="content">
              <div class="account">2305</div>
            </div>
          </div>
        </div>
      </div>
      <div class="container-box">
        <div class="title">文化&治理</div>
        <div class="acount-statistics">
          <div class="statistics-item gutter">
            <div class="label">学堂发布<br/>数量</div>
            <div class="content">
              <div class="account">1256</div>
            </div>
          </div>
          <div class="statistics-item gutter">
            <div class="label">话题<br/>数量</div>
            <div class="content">
              <div class="account">456667</div>
            </div>
          </div>
          <div class="statistics-item gutter">
            <div class="label">社区公告发布<br/>数量</div>
            <div class="content">
              <div class="account">598561</div>
            </div>
          </div>
          <div class="statistics-item">
            <div class="label">活动组织<br/>数量</div>
            <div class="content">
              <div class="account">1234</div>
            </div>
          </div>
          <div class="statistics-item">
            <div class="label">事故处置<br/>数量</div>
            <div class="content">
              <div class="account">3445</div>
            </div>
          </div>
          <div class="statistics-item">
            <div class="label">累计服务<br/>人次</div>
            <div class="content">
              <div class="account">4466713</div>
            </div>
          </div>
        </div>
      </div>
    </div> -->
  </div>
</template>

<script setup lang="ts">
import Right from '../../components/right/index.vue'
import AMap from '@/components/AMap.vue'
import { useRoute, useRouter } from 'vue-router'
import { onMounted, ref } from 'vue'
import { getUserInfo, login } from '@/api/index.ts'
import pic1 from '@/assets/img/aged.png'
import pic2 from '@/assets/img/building.png'
import pic3 from '@/assets/img/hands.png'
import pic4 from '@/assets/img/bigSchool.png'
import pic5 from '@/assets/img/hat.png'
import pic6 from '@/assets/img/menu-School.png'
const router = useRouter()
const route = useRoute()
onMounted(async () => {
  const result = await dd.getAuthCode({})
  const authCode = JSON.stringify(result, null, null)

  const res = await login({
    authCode,
    appCode: 'SZHZ-2'
  })
  const token = res.data
  const userRes = await getUserInfo({
    appCode: 'ZFYYJC-1'
  }, {
    token
    // token: 'eyJhbGciOiJIUzI1NiJ9.eyIkaW50X3Blcm1zIjpbImluc3RydWN0aW9uIiwic3VwZXJ2aXNlIiwicG9ydGFsIiwiZnJvbnRJbmRleCJdLCJzdWIiOiJvcmcucGFjNGouY29yZS5wcm9maWxlLkNvbW1vblByb2ZpbGUjOTk5OTk5OTk5OTk5OTkiLCJhbGlhc05hbWUiOiLmtYvor5XnlKjmiLciLCJsb2dpblR5cGUiOiIxIiwicm9sZXMiOiJbe1wiWkZZWUpDLTFcIjpcIlFZTERcIn1dIiwiZXh0VXNlcklkIjoiMTExMTExMTEiLCJhcHBDb2RlIjoiWkZZWUpDLTEiLCJ2ZXJzaW9uIjoxLjAsIm1vYmlsZU51bSI6IiIsIiRpbnRfcm9sZXMiOlsiUVlMRCJdLCJleHAiOjE3MTg2NDAwMDAsImlhdCI6MTYzMjI5OTUwNCwidXNlcm5hbWUiOiIxMTExMTExMSJ9.yR8LdH6L1s_G728ZV_Nry3J5tKSwB2Be6PCmA8KXKcY'
  })
  if (!userRes || !userRes.code || Number(userRes.code) !== 200) {
    router.push({
      path: '/403'
    })
  }
  aplus_queue.push({
    action: "aplus.setMetaInfo",
    arguments: ["_user_id", `${userRes.data.id}`]
  });
  aplus_queue.push({
    action: "aplus.setMetaInfo",
    arguments: ["_dev_id", `${userRes.data.mobileNum}`]
  });

  // 如采集用户信息是异步行为，需要先设置完用户信息后再执行这个START埋点
  // 此时被block住的日志会携带上用户信息逐条发出
  aplus_queue.push({
    action: 'aplus.setMetaInfo',
    arguments: ['_hold', 'START']
  });
})
const navList = ref([
  {
    pic: pic1,
    name: 'aged',
    title: '老人信息',
    id: 1
  },
  {
    pic: pic2,
    title: '康养机构',
    name: 'KyOrganization',
    id: 2
  },
  {
    pic: pic3,
    name: 'agedService',
    title: '养老服务',
    id: 3
  },
  {
    pic: pic4,
    name: 'education',
    title: '社区文化',
    id: 4
  },
  {
    pic: pic5,
    name: 'culture',
    title: '社区教育',
    id: 5
  },
  {
    pic: pic6,
    name: 'JyOrganization',
    title: '教育机构',
    id: 6
  }
])
const gotoPage = (name:String) => {
  router.push({
    name
  })
}
</script>

<style lang="less" scoped>
.home-container {
  width: 1590px;
  // background-color: #000;
  display: flex;
  justify-content: space-between;
}
.right-col {
  width: 608px;
}
.overall {
  width: 1156px;
}
.acount-statistics {
  display: flex;
  flex-wrap: wrap;
  .statistics-item {
    width: 33.32%;
    text-align: center;
    position: relative;
    &.gutter {
      margin-bottom: 24px;
    }
    &::after {
      content: "";
      width: 1px;
      height: 45px;
      display: block;
      position: absolute;
      background: #EFEFEF;
      top: 0;
      bottom: 0;
      right: 0;
      margin: auto;
    }
    &:nth-child(3n)::after {
      display: none;
    }
    .label {
      color: #999999;
      font-size: 18px;
    }
    .content {
      display: flex;
      align-items: center;
      justify-content: center;
      margin-top: 8px;
      .icon {
        width: 23px;
        height: 18px;
        margin-right: 8px;
        img {
          width: 100%;
          height: 100%;
          display: block;
        }
      }
      .account {
        font-weight: bold;
        font-size: 24px;
        color: #363A44;
      }
    }
    &:nth-child(2) {
      .icon {
        width: 20px;
        height: 20px;
      }
    }
  }
}
// 改
.overall-container-box{
  width: 1340px;
  height: 166px;
  background: #FFFFFF;
}
.right{
  margin-right: 24px;
}
.wenhua{
  // margin-top: 48px;
  display: flex;
  .container-box {
  width: 665px;
  height: 330px;
  background: #fff;
  padding: 24px;
  box-sizing: border-box;
  border-radius: 2px;
  border: 1px solid #EBEBEB;
  margin-bottom: 24px;
  .title {
    font-weight: bold;
    font-size: 20px;
    color: #333;
    margin-bottom: 16px;
  }
}
}
.shequ{
  width: 1340px;
  height: 162px;
  background: #FFFFFF;
  margin-bottom: 24px;
    .container-box {
    background: #fff;
    padding: 24px;
    box-sizing: border-box;
    border-radius: 2px;
    // border: 1px solid #EBEBEB;
  .title {
    font-weight: bold;
    font-size: 20px;
    color: #333;
    margin-bottom: 16px;
  }
  }
}
.menus {
    margin-left: 80px;
    margin-right: 80px;
    display: flex;
    margin-top: 24px;
    height: 166px;
    justify-content: space-between;
    .menu-item {
      text-align: center;
      display: flex;
      flex-direction: column;
      justify-content: flex-start;
      align-items: center;
      img {
        width: 80px;
        height: 80px;
        margin-bottom: 16px;
      }
    }
  }
.map-box{
  width: 1340px;
  height: 547px;
  .title {
    margin-left: 24px;
    font-weight: bold;
    font-size: 20px;
    color: #333;
    margin-bottom: 16px;
  }
  .map {
  margin-left: 24px;
  width: 1292px;
  height: 448px;
  }
  }
</style>